package HomeWorkNewYear;

public class ooDay03PolymorphicDemo {
    public static void main(String[] args) {
        ooDay03Master master = new ooDay03Master();
        ooDay02Dog dog=new ooDay02Dog("小黑",1,"黑");
        ooDay02Chick chick=new ooDay02Chick("小黄",1,"黄");
        ooDay02Fish fish=new ooDay02Fish("小蓝",1,"蓝");
        master.feed(dog);
        master.feed(chick);
        master.feed(fish);

        ooDay02Animal []animals=new ooDay02Animal[5];
        animals[0]=new ooDay02Dog("小黑",6,"黑");
        animals[1]=new ooDay02Dog("小白",5,"白");
        animals[2]=new ooDay02Fish("小黄",1,"黄");
        animals[3]=new ooDay02Fish("小粉",2,"粉");
        animals[4]=new ooDay02Chick("小蓝",3,"蓝");
        for (int i=0;i<animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof ooDay02Dog){
                ooDay02Dog dog1=(ooDay02Dog) animals[i];
                dog1.lookHome();
            }
            if (animals[i] instanceof ooDay02Chick){
                ooDay02Chick chick1=(ooDay02Chick) animals[i];
                chick1.layEggs();
            }
            if (animals[i] instanceof ooDay02Swim){
                ooDay02Swim s = (ooDay02Swim) animals[i];
                s.swim();
            }
        }
    }
}
